Skip to content

RTECO-1017 - Enrich User-Agent with agent/CI context and reuse Cursor…#3468

Open
fluxxBot wants to merge 2 commits into
masterfrom
RTECO-1017-CIdetect
Open

RTECO-1017 - Enrich User-Agent with agent/CI context and reuse Cursor…#3468
fluxxBot wants to merge 2 commits into
masterfrom
RTECO-1017-CIdetect

Conversation

@fluxxBot
Copy link
Copy Markdown
Contributor

@fluxxBot fluxxBot commented May 4, 2026

  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • The pull request is targeting the master branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....

Summary

Wires the invocation-context detection from jfrog-cli-core PR #1555 into jf:

  • Appends agent + CI info to the User-Agent header sent to Artifactory.
  • Reuses CURSOR_TRACE_ID (when invoked from Cursor) as the Uber Trace ID instead of generating a fresh one, so server-side logs correlate end-to-end with the agent's trace.

Motivation

RTECO-1017: differentiate human / CI / agent invocations of jf. Surface agent identity in every API call so support and observability can attribute traffic correctly without parsing metric payloads separately.

Changes

  • main.go:
    • setUberTraceIdToken reuses ExecutionContext.TraceID (currently CURSOR_TRACE_ID) when present; falls back to the existing 16-char hex generator otherwise.
    • clientutils.SetUserAgent now calls corecommands.EnrichUserAgent(base) which appends (agent; ci=<system>) to the base CLI User-Agent. Returns base unchanged when neither agent nor CI is detected.
  • go.mod — points at the published pre-release of jfrog-cli-core that contains the detection logic. Must be bumped to the final tagged version once core PR Allow option to disable the 'npm ls' command being triggered in the background during JFrog CLI run ( NPM )  #1555 merges.

Examples

Context User-Agent
Plain shell jfrog-cli-go/2.103.0
Claude Code jfrog-cli-go/2.103.0 (claude)
Cursor jfrog-cli-go/2.103.0 (cursor)
Cursor in GitHub Actions jfrog-cli-go/2.103.0 (cursor; ci=github_actions)
GitHub Actions, no agent jfrog-cli-go/2.103.0 (ci=github_actions)

Trace-ID propagation

CURSOR_TRACE_ID is reused when the detected agent is cursor. For all other agents, a fresh 16-char hex trace ID is generated as before. Gated on agent identity — prevents stale values leaked from an outer shell being used when a different agent is the real invoker.

Memoization (sync.Once in core)

DetectExecutionContext() is called from two places in main.goEnrichUserAgent and setUberTraceIdToken. Both return the same cached snapshot (memoized via sync.Once in core on first call). No divergence possible even if env mutates between calls.

@fluxxBot fluxxBot added the new feature Automatically generated release notes label May 4, 2026
…22-89ba093adf6b and refactor User-Agent setting in main.go
@fluxxBot fluxxBot added the safe to test Approve running integration tests on a pull request label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Automatically generated release notes safe to test Approve running integration tests on a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant